package com.dome.network1;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.UUID;
import java.util.concurrent.*;

//TCP服务端
public class Server {
    public static void main(String[] args) throws IOException {
        UUID uuid = UUID.randomUUID();
        //创建ServerSocket对象,将客户端上传的文件用网络写入本地中
        ServerSocket serverSocket=new ServerSocket(7777);
        //调用accept方法,如有接收到信息,就会生成一个accept对象
        Socket accept = serverSocket.accept();
        MyTcp mt=new MyTcp(accept);
        //创建线程池
        ThreadPoolExecutor executor = new ThreadPoolExecutor(2, 3, 7, TimeUnit.SECONDS, new ArrayBlockingQueue<>(5), Executors.defaultThreadFactory(), new ThreadPoolExecutor.AbortPolicy());
        executor.submit(mt);
        executor.shutdown();
    }
}
